package initialization

import (
	"common/globals"
	"context"
	"github.com/go-redis/redis/v8"
	"log"
)

func InitRedis() {
	cf := Config.Redis
	globals.Rdb = redis.NewClient(&redis.Options{
		Addr:     cf.Addr,
		Password: cf.Password,
		DB:       cf.Db,
	})
	err := globals.Rdb.Ping(context.Background()).Err()
	if err != nil {
		log.Fatalln("redis init fail")
	}
	log.Println(" init redis  success")
}
